<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head> 
		<meta charset="UTF-8" />
		<title> 用户管理</title>
		<link rel="stylesheet" href="../../../js/plugins/layui-v2.4.5/layui/css/layui.css" />
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/index.css" />
		<link rel="stylesheet" href="../../../font/iconfont.css" />
		<link rel="shortcut icon" href="../../../favicon.ico" />
		<script src="../../../js/jquery-3.3.1.min.js"></script>
		<script src="../../../js/plugins/layui-v2.4.5/layui/layui.js"></script>
		
	</head>
	<body class="p10">
		<div class="container p15">
			<fieldset class="layui-elem-field">
				<div class="layui-field-box">
					<div class="layui-inline">
						<input id="keyword" placeholder="关键字" class="layui-input layui-input-sm search_input">
					</div>
					<div class="layui-inline">
						<a class="layui-btn layui-btn-sm" id="btn-search" lay-filter="searchForm"><i class="layui-icon">&#xe615;</i>查询</a>
					</div>
					<div class="layui-inline f-right">
						<a class="layui-btn layui-btn-sm layui-btn-normal" data-type="addUser" id="add-disc"> <i class="layui-icon">&#xe61f;</i>新增</a>
					</div>
				</div>
			</fieldset>
			<div style="height: calc(100% - 70px)">
				<div class="layui-row">
					<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table> 
				</div>
			</div>
		</div>
		<script type="text/html" id="toolBar">
			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="peizhi">配置环节</a>
  			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		</script>
		<script type="text/html" id="toolType">
  			{{# if(d.fkProcesstype==0){ }}
			本页刷新
			{{# }else{ }}
			选项卡
			{{# } }}
		</script>
		<script type="text/html" id="toolstatus">
  			{{# if(d.status==0){ }}
			启动
			{{# }else{ }}
			未启动
			{{# } }}
		</script>
		<script>
			layui.use('table', function(){
				var table = layui.table;
			  	
				//方法级渲染
				table.render({
					id:'dg_user',
				    elem: '#LAY_table_user',
				    cols: [[
				      //{checkbox: true, fixed: true},
				      {field:'processname', align:'left', title: '流程名称'}
				      ,{field:'fkProcesstype', align:'left', title: '流程类型',  sort: true, toolbar: '#toolType'}
				      ,{field:'creater', align:'center', title: '添加人'}
				      ,{field:'created', align:'center', title: '创建时间'}
				      ,{field:'status', align:'center', title: '是否启用', toolbar: '#toolstatus'}
				      ,{fixed: 'right', width:200, align:'center', toolbar: '#toolBar'}
				    ]]
				    ,page: true
				    ,height: 300 
				    ,data: [{"created":"2019-03-25","creater":"admin","fkDept":"654edd23f44932f90b4a4fd4a5f7342d","fkProcesstype":"654edd23f44932f90b4a4fd4a5f7341d","id":"14ff339595224cb4ab6fe21b89f231e1","modified":"2019-03-25","processname":"新合同审批","status":true},{"created":"2019-03-25","creater":"admin","fkDept":"654edd23f44932f90b4a4fd4a5f7342d","fkProcesstype":"654edd23f44932f90b4a4fd4a5f7342d","id":"24bc873abc2e4541819f6e2c1286becc","modified":"2019-03-25","processname":"新意向书审批","status":true},{"created":"2019-04-17","creater":"admin","fkProcesstype":"1","id":"2743a3d5bea44c4daca7dfa0c5a8b78e","modified":"2019-04-18","processname":"ces11","status":false},{"created":"2019-03-25","creater":"admin","fkDept":"654edd23f44932f90b4a4fd4a5f7342d","fkProcesstype":"654edd23f44932f90b4a4fd4a5f7343d","id":"28ea398336384d41b4d050be0d55190d","modified":"2019-03-25","processname":"新变更协议审批","status":true},{"created":"2019-03-25","creater":"admin","fkDept":"654edd23f44932f90b4a4fd4a5f7342d","fkProcesstype":"654edd23f44932f90b4a4fd4a5f7344d","id":"345b13700a884cf19c53a0aad0da8013","modified":"2019-03-25","processname":"新终止协议审批","status":true}]
				});
				
				//监听工具条
				table.on('tool(user)', function(obj){
				    var data = obj.data;
				    if(obj.event == 'detail'){
				      layer.msg('ID：'+ data.id + ' 的查看操作');
				    } else if(obj.event == 'del'){
				      	layer.confirm('确认要删除吗，删除后不能恢复', function(index){
				        	//发送删除请求
				        	$.post("/common/modProcess/delete",{id:data.id},function(res){
				        		if(res.success){
				        			layer.msg(res.msg);
				        		}else{
				        			layer.msg(res.msg, function(){});
				        		}
				        		layui.table.reload('dg_user');
				        		layer.close(index);
				            },"json");
				      	});
				    } else if(obj.event == 'edit'){
				    	layer.open({
							title : [ '流程信息','font-size:18px;text-align:center;padding:0' ],
							type : 2,
							area : [ '600px', '406px' ],
							shade : [ 0.8, '#393D49' ],
							content :"process_edit.html"
						});
				    } else if(obj.event == 'peizhi'){
				    	layer.open({
							title : [ '环节配置','font-size:18px;text-align:center;padding:0' ],
							type : 2,
							area : [ '800px', '606px' ],
							shade : [ 0.8, '#393D49' ],
							content :"modProcessNode_index.html"
						});
				    }
				});
				  
				$('.demoTable .layui-btn').on('click', function(){
				    var type = $(this).data('type');
				    active[type] ? active[type].call(this) : '';
				});
			});
			
			
			$(function() {
				layui.use([ 'element', 'table', 'layer' ], function() {
					var element = layui.element;
				});
				
				//弹出框
				$("#add-disc").on("click",function() {
					layer.open({
						title : [ '流程信息','font-size:18px;text-align:center;padding:0' ],
						type : 2,
						shadeClose: true,
						area : [ '600px', '400px' ],
						shade : [ 0.8, '#393D49' ],
						content : "process_add.html"
					});
				})
				
				//查询
				$("#keyword").keyup(function (event) {
			        var e = event|| window.event;
			        if (e.keyCode == "13") {
			        	var keyword = $('#keyword').val();
			        	layui.table.reload('dg_user', {
					        page: {
					          curr: 1 //重新从第 1 页开始
					        }
					        ,where: {
					        	params:{keyword: keyword}
					        }
					    });
			        }
			    });
			})
			
		</script>
	</body>
</html>